# -*- coding: utf-8 -*-
# @Time    : 2024/11/29  14:28
# @Author  : Nabby
# @FileName: jasco_order_manage.py
# @Desc    :

from infrastructure.po.impl.jasco_order_impl import JascoOrderImpl
from infrastructure.po.impl.jasco_forecast_information_impl import JascoForecastInformationImpl
from infrastructure.po.impl.jasco_received_information_impl import JascoReceivedInformationImpl
from infrastructure.po.impl.jasco_declaration_information_impl import JascoDeclarationInformationImpl
from infrastructure.po.impl.jasco_loading_order_impl import JascoLoadingOrderImpl
from infrastructure.po.impl.jasco_logistics_trajectory_impl import JascoLogisticsTrajectoryImpl
from infrastructure.po.impl.jasco_cost_details_impl import JascoCostDetailsImpl
from infrastructure.po.impl.jasco_file_manage_impl import JascoFileManageImpl
from infrastructure.po.impl.user_impl import UserImpl
from infrastructure.utils.http import responser


class JascoOrderService(object):
    @classmethod
    def get_jasco_order_list(
        cls,
        user_id,
        order_code=None,
        logistics_code=None,
        destination=None,
        consignee=None,
        postcode=None,
        # keyword=None,
        page=1,
        page_size=999
    ):
        """
        查询jasco订单列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        # user_company = UserImpl.get_company_name(user_id)
        response_data = []
        jasco_order_list, total = JascoOrderImpl.get_jasco_order_list(
            order_code=order_code,
            logistics_code=logistics_code,
            destination=destination,
            consignee=consignee,
            postcode=postcode,
            # keyword=keyword,
            page=page,
            page_size=page_size,
            user_id=user_company
        )
        for jasco_order in jasco_order_list:
            response_data.append(
                {
                    "orderId": jasco_order.id,
                    "orderCode": jasco_order.code,
                    "orderStatus": jasco_order.status,
                    "orderType": jasco_order.type,
                    "logisticsCode": jasco_order.logistics_code,
                    "logisticsChannel": jasco_order.logistics_channel,
                    "destination": jasco_order.destination,
                    "receivingTime": jasco_order.receiving_time,
                    "consignee": jasco_order.consignee,
                    "consigneeCompany": jasco_order.consignee_company,
                    "consigneePhone": jasco_order.consignee_phone,
                    "consigneeEmail": jasco_order.consignee_email,
                    "postcode": jasco_order.postcode,
                    # "keyword": jasco_order.keyword,
                    "hasInsure": jasco_order.has_insure,
                    "clearanType": jasco_order.clearance_type,
                    "tradeClause": jasco_order.trade_clause,
                    "tfnVat": jasco_order.tfn_vat,
                    "tfnEori": jasco_order.tfn_eori,
                    "tfnEin": jasco_order.tfn_ein,
                    "tfnOther": jasco_order.tfn_other,
                    "packagesNum": jasco_order.packages_num,
                    "address1": jasco_order.address1,
                    "address2": jasco_order.address2,
                    "address3": jasco_order.address3,
                    "packagesWeight": jasco_order.packages_weight,
                    "packagesVolume": jasco_order.packages_volume,
                    "billingWeightSquaremeter": jasco_order.billing_weight_squaremeter,
                    "volumeDivisor": jasco_order.volume_divisor,
                    "createTime": jasco_order.create_time,
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def get_jasco_order_by_id(cls, id):
        """
        根据id查询jasco订单
        :param id:
        :return:
        """
        jasco_order = JascoOrderImpl.get_jasco_order_by_id(id)
        if not jasco_order:
            return responser.send(10052)
        response_data = {
            "orderId": jasco_order.id,
            "orderCode": jasco_order.code,
            "orderStatus": jasco_order.status,
            "orderType": jasco_order.type,
            "logisticsCode": jasco_order.logistics_code,
            "logisticsChannel": jasco_order.logistics_channel,
            "destination": jasco_order.destination,
            "receivingTime": jasco_order.receiving_time,
            "consignee": jasco_order.consignee,
            "consigneeCompany": jasco_order.consignee_company,
            "consigneePhone": jasco_order.consignee_phone,
            "consigneeEmail": jasco_order.consignee_email,
            "postcode": jasco_order.postcode,
            # "keyword": jasco_order.keyword,
            "hasInsure": jasco_order.has_insure,
            "clearanceType": jasco_order.clearance_type,
            "tradeClause": jasco_order.trade_clause,
            "tfnVat": jasco_order.tfn_vat,
            "tfnEori": jasco_order.tfn_eori,
            "tfnEin": jasco_order.tfn_ein,
            "tfnOther": jasco_order.tfn_other,
            "packagesNum": jasco_order.packages_num,
            "address1": jasco_order.address1,
            "address2": jasco_order.address2,
            "address3": jasco_order.address3,
            "packagesWeight": jasco_order.packages_weight,
            "packagesVolume": jasco_order.packages_volume,
            "billingWeightSquaremeter": jasco_order.billing_weight_squaremeter,
            "volumeDivisor": jasco_order.volume_divisor,
            "createTime": jasco_order.create_time,
            "updateTime": jasco_order.update_time
        }
        return responser.send(10000, data=response_data)

    @classmethod
    def add_order(
        cls,
        user_id,
        order_code,
        order_status=None,
        order_type=None,
        logistics_code=None,
        logistics_channel=None,
        receiving_time=None,
        consignee=None,
        consignee_company=None,
        consignee_phone=None,
        consignee_email=None,
        postcode=None,
        destination=None,
        has_insure=None,
        # keyword=None,
        clearance_type=None,
        trade_clause=None,
        tfn_vat=None,
        tfn_eori=None,
        tfn_ein=None,
        tfn_other=None,
        packages_num=None,
        address1=None,
        address2=None,
        address3=None,
        packages_weight=None,
        packages_volume=None,
        billing_weight_squaremeter=None,
        volume_divisor=None
    ):
        """
        添加jasco订单
        :param kwargs:
        :return:
        """
        add_order_code = JascoOrderImpl.add_jasco_order(
            user_id=user_id,
            order_code=order_code,
            status=order_status,
            type=order_type,
            logistics_code=logistics_code,
            logistics_channel=logistics_channel,
            receiving_time=receiving_time,
            consignee=consignee,
            consignee_company=consignee_company,
            consignee_phone=consignee_phone,
            consignee_email=consignee_email,
            postcode=postcode,
            destination=destination,
            has_insure=has_insure,
            # keyword=keyword,
            clearance_type=clearance_type,
            trade_clause=trade_clause,
            tfn_vat=tfn_vat,
            tfn_eori=tfn_eori,
            tfn_ein=tfn_ein,
            tfn_other=tfn_other,
            packages_num=packages_num,
            address1=address1,
            address2=address2,
            address3=address3,
            packages_weight=packages_weight,
            packages_volume=packages_volume,
            billing_weight_squaremeter=billing_weight_squaremeter,
            volume_divisor=volume_divisor
        )
        if add_order_code:
            return responser.send(10000)
        else:
            return responser.send(10041)

    @classmethod
    def edit_order(
        cls,
        order_id,
        order_code=None,
        order_status=None,
        order_type=None,
        logistics_code=None,
        logistics_channel=None,
        receiving_time=None,
        consignee=None,
        consignee_company=None,
        consignee_phone=None,
        consignee_email=None,
        postcode=None,
        destination=None,
        has_insure=None,
        # keyword=None,
        clearance_type=None,
        trade_clause=None,
        tfn_vat=None,
        tfn_eori=None,
        tfn_ein=None,
        tfn_other=None,
        packages_num=None,
        address1=None,
        address2=None,
        address3=None,
        packages_weight=None,
        packages_volume=None,
        billing_weight_squaremeter=None,
        volume_divisor=None
    ):
        """
        编辑jasco订单
        :param kwargs:
        :return:
        """
        edit_order = JascoOrderImpl.edit_jasco_order(
            id=order_id,
            order_code=order_code,
            status=order_status,
            type=order_type,
            logistics_code=logistics_code,
            logistics_channel=logistics_channel,
            receiving_time=receiving_time,
            consignee=consignee,
            consignee_company=consignee_company,
            consignee_phone=consignee_phone,
            consignee_email=consignee_email,
            postcode=postcode,
            destination=destination,
            has_insure=has_insure,
            # keyword=keyword,
            clearance_type=clearance_type,
            trade_clause=trade_clause,
            tfn_vat=tfn_vat,
            tfn_eori=tfn_eori,
            tfn_ein=tfn_ein,
            tfn_other=tfn_other,
            packages_num=packages_num,
            address1=address1,
            address2=address2,
            address3=address3,
            packages_weight=packages_weight,
            packages_volume=packages_volume,
            billing_weight_squaremeter=billing_weight_squaremeter,
            volume_divisor=volume_divisor
        )
        if edit_order:
            return responser.send(10000)
        else:
            return responser.send(10052)

    @classmethod
    def delete_order(cls, id):
        """
        删除jasco订单
        :param id:
        :return:
        """
        delete_order = JascoOrderImpl.delete_jasco_order(id)
        if delete_order:
            return responser.send(10000)
        else:
            return responser.send(10052)

    @classmethod
    def get_cargo_detail_overview(cls, order_id):
        """
        查询jasco订单货物明细概览
        :param order_id:
        :return:
        """
        response_data = []
        overview = JascoOrderImpl.get_jasco_order_by_id(id=order_id)
        if overview:
            response_data = {
                "packagesNum": overview.packages_num,
                "packagesWeight": overview.packages_weight,
                "packagesVolume": overview.packages_volume,
                "billingWeightSquaremeter": overview.billing_weight_squaremeter,
                "volumeDivisor": overview.volume_divisor
            }
            return responser.send(10000, data=response_data)
        else:
            return responser.send(10052)

    @classmethod
    def edit_cargo_detail_overview(
        cls,
        order_id,
        packages_num=None,
        packages_weight=None,
        packages_volume=None,
        billing_weight_squaremeter=None,
        volume_divisor=None
    ):
        """
        编辑jasco订单货物明细概览
        :param order_id:
        :return:
        """
        edit_overview = JascoOrderImpl.edit_cargo_detail_overview(
            id=order_id,
            packages_num=packages_num,
            packages_weight=packages_weight,
            packages_volume=packages_volume,
            billing_weight_squaremeter=billing_weight_squaremeter,
            volume_divisor=volume_divisor
        )
        if edit_overview:
            return responser.send(10000)
        else:
            return responser.send(10052)





    @classmethod
    def get_order_forecast_information_list(
        cls,
        order_id,
        page=1,
        page_size=999,
    ):
        """
        查询jasco订单预报信息列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        response_data = []
        forecast_information_list, total = JascoForecastInformationImpl.get_forecast_information_list(
            order_id=order_id,
            page=page,
            page_size=page_size,
        )

        for forecast_information in forecast_information_list:
            response_data.append(
                {
                    "forecastInformationId": forecast_information.id,
                    "cargoCode": forecast_information.cargo_code,
                    "length": forecast_information.length,
                    "width": forecast_information.width,
                    "height": forecast_information.height,
                    "grossWeight": forecast_information.gross_weight,
                    "volume": forecast_information.volume,
                    "createTime": forecast_information.create_time,
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def add_order_forecast_information(
        cls,
        order_id,
        cargo_code,
        length,
        width,
        height,
        gross_weight,
        volume
    ):
        """
        添加jasco订单预报信息
        :param kwargs:
        :return:
        """
        add_forecast_information = JascoForecastInformationImpl.add_forecast_information(
            order_id=order_id,
            cargo_code=cargo_code,
            length=length,
            width=width,
            height=height,
            gross_weight=gross_weight,
            volume=volume
        )
        if add_forecast_information:
            return responser.send(10000)
        else:
            return responser.send(10042)

    @classmethod
    def edit_order_forecast_information(
        cls,
        forecast_information_id,
        order_id,
        cargo_code,
        length,
        width,
        height,
        gross_weight,
        volume
    ):
        """
        编辑jasco订单预报信息
        :param kwargs:
        :return:
        """
        edit_forecast_information = JascoForecastInformationImpl.edit_forecast_information(
            id=forecast_information_id,
            order_id=order_id,
            cargo_code=cargo_code,
            length=length,
            width=width,
            height=height,
            gross_weight=gross_weight,
            volume=volume
        )
        if edit_forecast_information:
            return responser.send(10000)
        else:
            return responser.send(10044)

    @classmethod
    def delete_order_forecast_information(cls, id, order_id):
        """
        删除jasco订单预报信息
        :param id:
        :return:
        """
        delete_forecast_information = JascoForecastInformationImpl.delete_forecast_information(id, order_id)
        if delete_forecast_information:
            return responser.send(10000)
        else:
            return responser.send(10042)


    @classmethod
    def get_order_received_information_list(
        cls,
        order_id,
        page=1,
        page_size=999,
    ):
        """
        查询jasco订单预报信息列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        response_data = []
        received_information_list, total = JascoReceivedInformationImpl.get_received_information_list(
            order_id=order_id,
            page=page,
            page_size=page_size,
        )
        for received_information in received_information_list:
            response_data.append(
                {
                    "receivedInformationId": received_information.id,
                    "cargoCode": received_information.cargo_code,
                    "length": received_information.length,
                    "width": received_information.width,
                    "height": received_information.height,
                    "actualWeight": received_information.actual_weight,
                    "volume": received_information.volume,
                    "volumetricWeight": received_information.volumetric_weight,
                    "billingWeight": received_information.billing_weight,
                    "billingSquaremeter": received_information.billing_squaremeter,
                    "subBillCode": received_information.sub_bill_code,
                    "transportationStatus": received_information.transportation_status,
                    "createTime": received_information.create_time,
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def add_order_received_information(
        cls,
        order_id,
        cargo_code,
        length,
        width,
        height,
        actual_weight,
        volume,
        volumetric_weight,
        billing_weight,
        billing_squaremeter,
        sub_bill_code,
        transportation_status
    ):
        """
        添加jasco订单收货信息
        :param kwargs:
        :return:
        """
        add_received_information = JascoReceivedInformationImpl.add_received_information(
            order_id=order_id,
            cargo_code=cargo_code,
            length=length,
            width=width,
            height=height,
            actual_weight=actual_weight,
            volume=volume,
            volumetric_weight=volumetric_weight,
            billing_weight=billing_weight,
            billing_squaremeter=billing_squaremeter,
            sub_bill_code=sub_bill_code,
            transportation_status=transportation_status
        )
        if add_received_information:
            return responser.send(10000)
        else:
            return responser.send(10043)

    @classmethod
    def edit_order_received_information(
        cls,
        received_information_id,
        order_id,
        cargo_code,
        length,
        width,
        height,
        actual_weight,
        volume,
        volumetric_weight,
        billing_weight,
        billing_squaremeter,
        sub_bill_code,
        transportation_status
    ):
        """
        编辑jasco订单收货信息
        """
        edit_received_information = JascoReceivedInformationImpl.edit_received_information(
            id=received_information_id,
            order_id=order_id,
            cargo_code=cargo_code,
            length=length,
            width=width,
            height=height,
            actual_weight=actual_weight,
            volume=volume,
            volumetric_weight=volumetric_weight,
            billing_weight=billing_weight,
            billing_squaremeter=billing_squaremeter,
            sub_bill_code=sub_bill_code,
            transportation_status=transportation_status
        )
        if edit_received_information:
            return responser.send(10000)
        else:
            return responser.send(10045)

    @classmethod
    def delete_order_received_information(cls, id, order_id):
        """
        删除jasco订单收货信息
        :param id:
        :return:
        """
        delete_received_information = JascoReceivedInformationImpl.delete_received_information(id, order_id)
        if delete_received_information:
            return responser.send(10000)
        else:
            return responser.send(10044)

    @classmethod
    def get_order_declaration_information_list(
        cls,
        order_id,
        page=1,
        page_size=999,
    ):
        """
        查询jasco订单预报信息列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        response_data = []
        declaration_information_list, total = JascoDeclarationInformationImpl.get_declaration_information_list(
            order_id=order_id,
            page=page,
            page_size=page_size,
        )
        for declaration_information in declaration_information_list:
            response_data.append(
                {
                    "totalProducts": declaration_information.total_products,
                    "declarationInformationId": declaration_information.id,
                    "declaredValue": declaration_information.declared_value,
                    "nameQuantity": declaration_information.name_quantity,
                    "englishName": declaration_information.english_name,
                    "chineseName": declaration_information.chinese_name,
                    "customsCode": declaration_information.customs_code,
                    "productsNum": declaration_information.products_num,
                    "chineseMaterial": declaration_information.chinese_material,
                    "englishMaterial": declaration_information.english_material,
                    "chineseUse": declaration_information.chinese_use,
                    "englishUse": declaration_information.english_use,
                    "brand": declaration_information.brand,
                    "model": declaration_information.model,
                    "onlineLink": declaration_information.online_link,
                    "productPicture": declaration_information.product_picture,
                    "unit": declaration_information.unit,
                    "price": declaration_information.price,
                    "currency": declaration_information.currency,
                    "totalPrice": declaration_information.total_price,
                    "netWeight": declaration_information.net_weight,
                    "sourceArea": declaration_information.source_area,
                    "finalDestination": declaration_information.final_destination,
                    "createTime": declaration_information.create_time,
                    "updateTime": declaration_information.update_time
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def add_order_declaration_information(
        cls,
        order_id,
        total_products,
        declared_value,
        name_quantity,
        english_name,
        chinese_name,
        customs_code,
        products_num,
        chinese_material,
        english_material,
        chinese_use,
        english_use,
        brand,
        model,
        online_link,
        product_picture,
        unit,
        price,
        currency,
        total_price,
        net_weight,
        source_area,
        final_destination,
    ):
        """
        添加jasco订单申报信息
        :param kwargs:
        :return:
        """
        add_declaration_information = JascoDeclarationInformationImpl.add_declaration_information(
            order_id=order_id,
            total_products=total_products,
            declared_value=declared_value,
            name_quantity=name_quantity,
            english_name=english_name,
            chinese_name=chinese_name,
            customs_code=customs_code,
            products_num=products_num,
            chinese_material=chinese_material,
            english_material=english_material,
            chinese_use=chinese_use,
            english_use=english_use,
            brand=brand,
            model=model,
            online_link=online_link,
            product_picture=product_picture,
            unit=unit,
            price=price,
            currency=currency,
            total_price=total_price,
            net_weight=net_weight,
            source_area=source_area,
            final_destination=final_destination
        )
        if add_declaration_information:
            return responser.send(10000)

    @classmethod
    def edit_order_declaration_information(
        cls,
        declaration_information_id,
        order_id,
        total_products,
        declared_value,
        name_quantity,
        english_name,
        chinese_name,
        customs_code,
        products_num,
        chinese_material,
        english_material,
        chinese_use,
        english_use,
        brand,
        model,
        online_link,
        product_picture,
        unit,
        price,
        currency,
        total_price,
        net_weight,
        source_area,
        final_destination,
    ):
        """
        编辑jasco订单申报信息
        """
        edit_declaration_information = JascoDeclarationInformationImpl.edit_declaration_information(
            id=declaration_information_id,
            order_id=order_id,
            total_products=total_products,
            declared_value=declared_value,
            name_quantity=name_quantity,
            english_name=english_name,
            chinese_name=chinese_name,
            customs_code=customs_code,
            products_num=products_num,
            chinese_material=chinese_material,
            english_material=english_material,
            chinese_use=chinese_use,
            english_use=english_use,
            brand=brand,
            model=model,
            online_link=online_link,
            product_picture=product_picture,
            unit=unit,
            price=price,
            currency=currency,
            total_price=total_price,
            net_weight=net_weight,
            source_area=source_area,
            final_destination=final_destination
        )
        if edit_declaration_information:
            return responser.send(10000)
        else:
            return responser.send(10048)

    @classmethod
    def delete_order_declaration_information(cls, id, order_id):
        """
        删除jasco订单申报信息
        :param id:
        :return:
        """
        delete_declaration_information = JascoDeclarationInformationImpl.delete_declaration_information(id, order_id)
        if delete_declaration_information:
            return responser.send(10000)
        else:
            return responser.send(10053)

    @classmethod
    def get_order_loading_order_list(
            cls,
            declaration_information_id,
            page=1,
            page_size=999,
    ):
        """
        查询jasco订单预报信息列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        response_data = []
        loading_order_list, total = JascoLoadingOrderImpl.get_loading_order_list(
            declaration_information_id=declaration_information_id,
            page=page,
            page_size=page_size,
        )
        for loading_order in loading_order_list:
            response_data.append(
                {
                    "loadingOrderId": loading_order.id,
                    "containerNumber": loading_order.container_number,
                    "englishName": loading_order.english_name,
                    "chineseName": loading_order.chinese_name,
                    "customsCode": loading_order.customs_code,
                    "productsNum": loading_order.products_num,
                    "chineseMaterial": loading_order.chinese_material,
                    "englishMaterial": loading_order.english_material,
                    "chineseUse": loading_order.chinese_use,
                    "englishUse": loading_order.english_use,
                    "brand": loading_order.brand,
                    "model": loading_order.model,
                    "unit": loading_order.unit,
                    "price": loading_order.price,
                    "currency": loading_order.currency,
                    "totalPrice": loading_order.total_price,
                    "netWeight": loading_order.net_weight,
                    "sourceArea": loading_order.source_area,
                    "finalDestination": loading_order.final_destination,
                    "createTime": loading_order.create_time,
                    "updateTime": loading_order.update_time
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def add_order_loading_order(
            cls,
            declaration_information_id,
            container_number,
            english_name,
            chinese_name,
            customs_code,
            products_num,
            chinese_material,
            english_material,
            chinese_use,
            english_use,
            brand,
            model,
            unit,
            price,
            currency,
            total_price,
            net_weight,
            source_area,
            final_destination
    ):
        """
        添加jasco订单申报信息-装箱单
        :param kwargs:
        :return:
        """
        add_loading_order = JascoLoadingOrderImpl.add_loading_order(
            declaration_information_id=declaration_information_id,
            container_number=container_number,
            english_name=english_name,
            chinese_name=chinese_name,
            customs_code=customs_code,
            products_num=products_num,
            chinese_material=chinese_material,
            english_material=english_material,
            chinese_use=chinese_use,
            english_use=english_use,
            brand=brand,
            model=model,
            unit=unit,
            price=price,
            currency=currency,
            total_price=total_price,
            net_weight=net_weight,
            source_area=source_area,
            final_destination=final_destination
        )
        if add_loading_order:
            return responser.send(10000)

    @classmethod
    def edit_order_loading_order(
            cls,
            loading_order_id,
            declaration_information_id,
            container_number,
            english_name,
            chinese_name,
            customs_code,
            products_num,
            chinese_material,
            english_material,
            chinese_use,
            english_use,
            brand,
            model,
            unit,
            price,
            currency,
            total_price,
            net_weight,
            source_area,
            final_destination
    ):
        """
        编辑jasco订单申报信息
        """
        edit_loading_order = JascoLoadingOrderImpl.edit_loading_order(
            id=loading_order_id,
            declaration_information_id=declaration_information_id,
            container_number=container_number,
            english_name=english_name,
            chinese_name=chinese_name,
            customs_code=customs_code,
            products_num=products_num,
            chinese_material=chinese_material,
            english_material=english_material,
            chinese_use=chinese_use,
            english_use=english_use,
            brand=brand,
            model=model,
            unit=unit,
            price=price,
            currency=currency,
            total_price=total_price,
            net_weight=net_weight,
            source_area=source_area,
            final_destination=final_destination
        )
        if edit_loading_order:
            return responser.send(10000)
        else:
            return responser.send(10049)

    @classmethod
    def delete_order_loading_order(cls, loading_order_id, declaration_information_id):
        """
        删除jasco订单申报信息
        :param id:
        :return:
        """
        delete_loading_order = JascoLoadingOrderImpl.delete_loading_order(id=loading_order_id, declaration_information_id=declaration_information_id)
        if delete_loading_order:
            return responser.send(10000)
        else:
            return responser.send(10049)


    @classmethod
    def get_cost_details_list(
            cls,
            order_id,
            page=1,
            page_size=999,
    ):
        """
        查询jasco订单预报信息列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        response_data = []
        cost_details_list, total = JascoCostDetailsImpl.get_cost_details_list(
            order_id=order_id,
            page=page,
            page_size=page_size,
        )
        for cost_detail in cost_details_list:
            response_data.append(
                {
                    "costDetailId": cost_detail.id,
                    "item": cost_detail.item,
                    "cost": cost_detail.cost,
                    "currency": cost_detail.currency,
                    "ssr": cost_detail.ssr,
                    "settlementStatus": cost_detail.settlement_status,
                    "orderId": cost_detail.order_id,
                    "createTime": cost_detail.create_time,
                    "updateTime": cost_detail.update_time
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def add_cost_details(
            cls,
            order_id,
            item,
            cost,
            currency,
            ssr,
            settlement_status
    ):
        """
        添加jasco订单申报信息
        :param kwargs:
        :return:
        """
        add_cost_details = JascoCostDetailsImpl.add_cost_details(
            order_id=order_id,
            item=item,
            cost=cost,
            currency=currency,
            ssr=ssr,
            settlement_status=settlement_status
        )
        if add_cost_details:
            return responser.send(10000)

    @classmethod
    def edit_cost_details(
            cls,
            cost_detail_id,
            order_id,
            item,
            cost,
            currency,
            ssr,
            settlement_status
    ):
        """
        编辑jasco订单申报信息
        """
        edit_cost_details = JascoCostDetailsImpl.edit_cost_details(
            id=cost_detail_id,
            order_id=order_id,
            item=item,
            cost=cost,
            currency=currency,
            ssr=ssr,
            settlement_status=settlement_status
        )
        if edit_cost_details:
            return responser.send(10000)
        else:
            return responser.send(10050)

    @classmethod
    def delete_cost_details(cls, cost_detail_id, order_id):
        """
        删除jasco订单申报信息
        :param id:
        :return:
        """
        delete_cost_details = JascoCostDetailsImpl.delete_cost_details(id=cost_detail_id, order_id=order_id)
        if delete_cost_details:
            return responser.send(10000)
        else:
            return responser.send(10050)


    @classmethod
    def get_logistics_trajectory_list(
            cls,
            order_id,
            page=1,
            page_size=999,
    ):
        """
        查询jasco物流信息列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        response_data = []
        logistics_trajectory_list, total = JascoLogisticsTrajectoryImpl.get_logistics_trajectory_list(
            order_id=order_id,
            page=page,
            page_size=page_size,
        )
        for logistics_trajectory in logistics_trajectory_list:
            response_data.append(
                {
                    "logisticsTrajectoryId": logistics_trajectory.id,
                    "status": logistics_trajectory.status,
                    "date": logistics_trajectory.date,
                    "content": logistics_trajectory.content,
                    "location": logistics_trajectory.location,
                    "createTime": logistics_trajectory.create_time,
                    "updateTime": logistics_trajectory.update_time
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def add_logistics_trajectory(
            cls,
            order_id,
            status,
            date,
            content,
            location
    ):
        """
        添加jasco物流信息
        :param kwargs:
        :return:
        """
        add_logistics_trajectory = JascoLogisticsTrajectoryImpl.add_logistics_trajectory(
            order_id=order_id,
            status=status,
            date=date,
            content=content,
            location=location
        )
        if add_logistics_trajectory:
            return responser.send(10000)

    @classmethod
    def edit_logistics_trajectory(
            cls,
            logistics_trajectory_id,
            order_id,
            status,
            date,
            content,
            location
    ):
        """
        编辑jasco物流信息
        """
        edit_logistics_trajectory = JascoLogisticsTrajectoryImpl.edit_logistics_trajectory(
            id=logistics_trajectory_id,
            order_id=order_id,
            status=status,
            date=date,
            content=content,
            location=location
        )
        if edit_logistics_trajectory:
            return responser.send(10000)
        else:
            return responser.send(10051)

    @classmethod
    def delete_logistics_trajectory(cls, logistics_trajectory_id, order_id):
        """
        删除jasco物流信息
        :param id:
        :return:
        """
        delete_logistics_trajectory = JascoLogisticsTrajectoryImpl.delete_logistics_trajectory(id=logistics_trajectory_id, order_id=order_id)
        if delete_logistics_trajectory:
            return responser.send(10000)
        else:
            return responser.send(10051)

    @classmethod
    def get_file_list(
            cls,
            order_id,
            page=1,
            page_size=999,
    ):
        """
        查询jasco订单预报信息列表
        :param page: 页码
        :param page_size: 每页数量
        :return:
        """
        response_data = []
        file_list, total = JascoFileManageImpl.get_file_manage_list(
            order_id=order_id,
            page=page,
            page_size=page_size,
        )
        for jasco_file in file_list:
            response_data.append(
                {
                    "fileId": jasco_file.id,
                    "type": jasco_file.type,
                    "fileName": jasco_file.file_name,
                    "source": jasco_file.source,
                    "uploadTime": jasco_file.create_time,
                    "remark": jasco_file.remark,
                    "filePath": jasco_file.file_path,
                    "createTime": jasco_file.create_time,
                    "updateTime": jasco_file.update_time,
                    "etd": jasco_file.etd,
                    "pol": jasco_file.pol,
                    "companyName": jasco_file.company_name,
                    "linkman": jasco_file.linkman,
                    "phone": jasco_file.phone,
                    "email": jasco_file.email,
                    "invoiceNumber": jasco_file.invoice_number,
                    "goodsName": jasco_file.goods_name,
                    "loadingTime": jasco_file.loading_time,
                    "totalPackages": jasco_file.total_packages,
                    "totalWeight": jasco_file.total_weight,
                    "totalVolume": jasco_file.total_volume,
                    "atd": jasco_file.atd,
                    "actualPol": jasco_file.actual_pol,
                    "eta": jasco_file.eta,
                    "pod": jasco_file.pod,
                    "vel": jasco_file.vel,
                    "mbl": jasco_file.mbl,
                    "hbl": jasco_file.hbl,
                    "deliverTo": jasco_file.deliver_to,
                    "terms": jasco_file.terms
                }
            )
        return responser.send(10000, data={"total": total, "data": response_data})

    @classmethod
    def add_file(
            cls,
            order_id,
            type,
            file_name,
            source,
            remark,
            file_path,
            etd,
            pol,
            company_name,
            linkman,
            phone,
            email,
            invoice_number,
            goods_name,
            loading_time,
            total_packages,
            total_weight,
            total_volume,
            atd,
            actual_pol,
            eta,
            pod,
            vel,
            mbl,
            hbl,
            deliver_to,
            terms
    ):
        """
        添加jasco订单申报信息
        :param kwargs:
        :return:
        """
        add_file = JascoFileManageImpl.add_file(
            order_id=order_id,
            type=type,
            file_name=file_name,
            source=source,
            remark=remark,
            file_path=file_path,
            etd=etd,
            pol=pol,
            company_name=company_name,
            linkman=linkman,
            phone=phone,
            email=email,
            invoice_number=invoice_number,
            goods_name=goods_name,
            loading_time=loading_time,
            total_packages=total_packages,
            total_weight=total_weight,
            total_volume=total_volume,
            atd=atd,
            actual_pol=actual_pol,
            eta=eta,
            pod=pod,
            vel=vel,
            mbl=mbl,
            hbl=hbl,
            deliver_to=deliver_to,
            terms=terms
        )
        if add_file:
            return responser.send(10000)

    # @classmethod
    # def delete_file(cls, file_id, order_id):
    #     """
    #     删除jasco订单申报信息
    #     :param id:
    #     :return:
    #     """
    #     delete_file = JascoFileManageImpl.delete_file(id=file_id, order_id=order_id)
    #     if delete_file:
    #         return responser.send(10000)
    #     else:
    #         return responser.send(10054)
